<TeXmacs|1.99.16>

<project|rehash.tm>

<style|tmmanual>

<\body>
  <section|Recognising a hash from an URI>

  remirror can sometimes detect the hash of a resource from the URL remirror
  is asked to download (when no suitable hash is found, remirror will just
  download from the URL). This code is implemented in the module
  <scm|(remirror recognise-hash-uri)>. Its entry point is a single procedure
  <scm|recognise-url?>. Some other procedures are exported as well that may
  be useful for testing part of the functionality.

  <\explain>
    <scm|(recognise-url? <scm-arg|filename>)><explain-synopsis|Try to exact a
    hash from an URL>
  <|explain>
    Try to figure out what hash <var|filename> refers to, purely based upon
    the string <var|filename> itself, without any side effects. The result is
    <scm|#f> if no hash could be detected at all, or if something is found, a
    list whose head <var|type> defines the nature of the information found.
    At time of writing, the following can be returned:

    <\description>
      <item*|<scm|(sha256 ...)>>SHA256 of a file, as a bytevector

      <item*|<scm|(unknown-narinfo <scm-arg|common> <scm-arg|hash>)>>A
      narinfo about something in the store, identified by some hash, as in
      <samp|/gnu/store/<var|hash>-some-other-stuff>. <var|hash> is a string.
      <var|common> is the prefix shared (in practice) by the narinfo and
      substitute.

      <\warning>
        Guix uses the extensional store model!
      </warning>

      <\remark>
        Some (possibly avoidable) heuristics are used to match the narinfo
        and substitute. In practice, <shell|guix publish> follows some rigid
        conventions, so this shouldn't form a problem in practice.
      </remark>

      <item*|<scm|(unknown-substitute <scm-arg|common> <scm-arg|compression>
      <scm-arg|hash> <scm-arg|name>)>>Like the former, but for the substitute
      itself. A compression method can be specified (as a string), or
      <scm|"none"> if not compressed. <var|name> is the
      <samp|some-other-stuff> in the example of <scm|unknown-narinfo>. See
      <samp|unknown-narinfo> for <var|common>.
    </description>
  </explain>
</body>

<\initial>
  <\collection>
    <associate|save-aux|false>
  </collection>
</initial>